package com.back.controller;

import com.back.model.dto.ExamsQueryDTO;
import com.back.model.entity.Exams;
import com.back.model.reslut.PageData;
import com.back.model.reslut.Result;
import com.back.service.ExamsService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/exam")
public class ExamController {

    @Resource
    private ExamsService examsService;

    @PostMapping("/create")
    public Result<Exams> createExams(@RequestBody Exams Exams) {
        Exams exams = examsService.createExams(Exams);
        return Result.successData(exams);
    }

    @PostMapping("/push")
    public Result<Exams> pushExams(Integer examsId) {
        examsService.pushExams(examsId);
        return Result.success();
    }


    @PostMapping("/one")
    public Result<Exams> getExams(@RequestBody ExamsQueryDTO examsQueryDTO) {
        Exams exams = examsService.getExams(examsQueryDTO);
        return Result.successData(exams);
    }

    /**
     *
     * @return
     */
    @PostMapping("/list")
    public Result<PageData<Exams>> getExamsList(@RequestBody ExamsQueryDTO examsQueryDTO) {
        PageData<Exams> examsList = examsService.getExamsList(examsQueryDTO);
        return Result.successData(examsList);
    }
}
